# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器，以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。

# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8070
EXPOSE 8071
# RUN chmod 777 /
# RUN mkdir -p /app/wwwroot



# 此阶段用于生成服务项目
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Directory.Packages.props", "."]
COPY ["DataChangeTools.WebApi/DataChangeTools.WebApi.csproj", "DataChangeTools.WebApi/"]
COPY ["DataChangeTools.WebApi.IRepository/DataChangeTools.WebApi.IRepository.csproj", "DataChangeTools.WebApi.IRepository/"]
COPY ["DataChangeTools.WebApi.Model/DataChangeTools.WebApi.Model.csproj", "DataChangeTools.WebApi.Model/"]
COPY ["DataChangeTools.WebApi.Repository/DataChangeTools.WebApi.Repository.csproj", "DataChangeTools.WebApi.Repository/"]
COPY ["DataChangeTools.WebApi.DAL/DataChangeTools.WebApi.DAL.csproj", "DataChangeTools.WebApi.DAL/"]
COPY ["DataChangeTools.WebApi.Common/DataChangeTools.WebApi.Common.csproj", "DataChangeTools.WebApi.Common/"]
RUN dotnet restore "./DataChangeTools.WebApi/DataChangeTools.WebApi.csproj"
COPY . .
WORKDIR "/src/DataChangeTools.WebApi"
RUN dotnet build "./DataChangeTools.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build

# 此阶段用于发布要复制到最终阶段的服务项目
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./DataChangeTools.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# 此阶段在生产中使用，或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# RUN  mkdir -p /app/packages
# 确保 wwwroot 目录存在并设置权限
# RUN mkdir -p /app/wwwroot && chmod -R 777 /app/wwwroot

ENTRYPOINT ["dotnet", "DataChangeTools.WebApi.dll","--urls", "http://*:8070"]